<template>
  <div>
    <el-form :model="formData" label-width="80px" ref="form" :rules="rules">
      <el-form-item label="分类名称" prop="title">
        <el-input v-model="formData.title" placeholder="请输入分类名称"></el-input>
      </el-form-item>      
      <el-form-item>  
        <el-button type="primary" @click="submit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {create} from "@/api/shop/goodscate"

  export default {
    data(){
      return {
        formData:{
          title:'',
        },
        rules:{
          title:[
            {required:true,message:'请输入分类名称'}
          ]
        }
      }
    },
    methods:{
      submit(){
        this.$refs.form.validate(valid=>{
          if(valid){
            create(this.formData).then(res=>{
              this.$message.success("新增成功");
              this.$emit("success")
            })
          }          
        })
      }
    }
  }
</script>

<style scoped>

</style>